#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    int countBattleships(vector<vector<char>>& board)
    {
        int battleship = 0;
        int row = board.size();
        int col = board[0].size();
        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                if (board[i][j] == 'X')
                {
                    board[i][j] = '.';
                    for (int k = i + 1; k < row && board[k][j] == 'X'; k++)
                        board[k][j] = '.';
                    for (int k = j + 1; k < col && board[i][k] == 'X'; k++)
                        board[i][k] = '.';
                    battleship++;
                }
            }
        }
        return battleship;
    }
};